package com.travelparadise.tests;

import java.util.ArrayList;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;

import com.travelparadise.dao.CommandeDao;
import com.travelparadise.domain.Commande;
import com.travelparadise.domain.Reservation;

public class TestCommandeDao extends TestCase {
	private CommandeDao commandeDao = null ;
	
	@Override
	protected void setUp() throws Exception {
		ApplicationContext springContext = SpringContextForTest.getSpringContext();
		this.commandeDao = (CommandeDao ) springContext.getBean("commandeDaoHibernate");
	}
	
	public void testGetCommandeById(){
		System.out.println("test de getById");
		Commande c=commandeDao.getById(1);
		for (Reservation r:c.getReservations()){
			System.out.println(r.toString());
		}
		System.out.println("**********************************");
	}
	
	public void testFindCommandesByIdClient() {
		System.out.println("testFindCommandesByIdClient");
		ArrayList<Commande> alcommandes= (ArrayList<Commande>) commandeDao.findCommandesByIdClient(1);
		for (Commande c:alcommandes){
			for (Reservation r:c.getReservations()){
				System.out.println(r.toString());
			}
		}
		System.out.println("**********************************");
	}

}
